package com.cloud.demo.common.web.exception;

import com.cloud.demo.common.web.domain.respomse.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionAdvice {
    @ExceptionHandler(SysException.class)
    @ResponseBody
    public Result runTimeException(SysException s){
        return Result.build(s.getResultEnum(),null);

    }
    @ExceptionHandler(BusException.class)
    @ResponseBody
    public Result runTimeException(BusException b){
        return Result.build(b.getResultEnum(),b.getObject());

    }
}
